// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
let viewconfig = {
    btn_close:{
        node:null,
        name:"btn_close",
        eventType:"click",
        cb:"onBtnCloseClick"
    },
    my_coin:{
        node:null,
        name:"my_coin",
    },
    btnOpen:{
        node:null,
        name:"btn_open",
        eventType:"click",
        cb:"onBtnOpenClick"
    },
    con:{
        node:null,
        name:"con"
    }
}
let panelBase = require("panelBase");
cc.Class({
    extends: panelBase,

    properties: {
        
    },

    init(){
        this._super(viewconfig);
        this.isInited = true;
        this.onHide();
    },

    onShow(){
        this._super();
        //测试
        // setTimeout(()=>{
        //     this.updateInfo(viewconfig["my_coin"].node,"我的金币:10086",cc.Label);
        //     this.updateInfo(viewconfig["con"].node,"每3000个金币开一个红包",cc.Label); 
        // },1000)
        this.updateInfo(viewconfig["my_coin"].node,`我的金币${cc.tg.cakeRoom.accGold}`,cc.Label)
    },
    onBtnCloseClick(){
        this.onHide();
    },
    onBtnOpenClick(){   
        //测试广告
        cc.log("on click coin test");
        
        
        if(cc.sys.isNative)
        {
            cc.tg.adDataCenter.toShowAd("coin");
        }
        else
        {
            cc.tg.jcj.onOpenHBAdOver();
        }

       // this.onHide();
    },


    onDestroy(){
        for(let key in viewConfig)
        {
            viewConfig[key].node = null;
        }
    }
});
